<?php

/**
 * Library :: DAL (Data Access Layer) :: DataObject
 *
 * Warlock is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 *
 * @package    warlock
 * @author     David Cole <neophyte@sourcetutor.com>
 * @license    GNU/GPL v2
 */

// Object Dependencies
using('Engine.DAL.DataObject');

class DAL_DataObject_page extends DAL_DataObject
{
    function __construct()
    {
        parent::__construct();
        
        // Table Properties
        $this->Table      = 'w_ext_pages';
        $this->PrimaryKey = 'id';      
        
        // Field Definitions
        $this->Fields['id']               = array('type' => 'INTEGER', 'size' => '10', 'unsigned' => true, 'autoincrement' => true);
        $this->Fields['nid']              = array('type' => 'INTEGER', 'size' => '10', 'unsigned' => true);    
        
        /*
         * Data Object Relationships
         */

        // Joins Current Node Summary Data
        $this->Relationships[] = array('table'  => 'w_engine_node',
                                       'do'     => 'node',
                                       'type'   => 'CASCADE',
                                       'fields' => array('uid'              => 'n_uid',
                                                         'type'             => 'n_type',
                                                         'status'           => 'n_status',
                                                         'title'            => 'n_title',
                                                         'teaser'           => 'n_teaser',
                                                         'body'             => 'n_body',
                                                         'created'          => 'n_created',
                                                         'changed'          => 'n_changed',
                                                         'meta_robots'      => 'n_meta_robots',
                                                         'meta_description' => 'n_meta_description',
                                                         'meta_keywords'    => 'n_meta_keywords'),
                                       'relate' => array('nid' => 'id'));           
                                                                               
        // Join User Data
        $this->Relationships[] = array('table'  => 'w_engine_users',
                                       'do'     => 'user',
                                       'fields' => array('id'           => 'u_id',
                                                         'email'        => 'u_email',
                                                         'name'         => 'u_name',
                                                         'display_name' => 'u_display_name',
                                                         'avatar'       => 'u_avatar'),
                                       'relate' => array('w_engine_node.uid' => 'id'));                                                                         
    }
}

?>